package everyday;

import java.net.Inet4Address;
import java.util.*;

public class Day09
{
    public static void main(String[] args)
    {
        // 用hashmap 取代数组
        HashMap<String, HashMap<Integer, Integer>> desc = new HashMap<>();
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0;i < n;i++){
            String action = in.next();
            if (action.equals("Add")){
                String area = in.next();
                int x = in.nextInt();
                int y = in.nextInt();
                HashMap<Integer, Integer> map = new HashMap<>();
                map.put(x, y);
                desc.put(area, map);
            }else if (action.equals("Query")){
                String area = in.nextLine();
                char[] tmp = area.toCharArray();
                StringBuilder sb = new StringBuilder();
                for (int p = 1;p < tmp.length;p++){
                    sb.append(tmp[p]);
                }
                if (desc.get(sb.toString()) != null){
                    System.out.println("yes");
                    HashMap<Integer, Integer> map = desc.get(sb.toString());
                    for(Map.Entry<Integer, Integer> a : map.entrySet()){
                        System.out.println(a.getKey()+" "+a.getValue());
                    }
                }else{
                    System.out.println("no");
                }
            }else if (action.equals("Change")){
                String area = in.next();
                int x = in.nextInt();
                int y = in.nextInt();
                boolean flag = false;
                if (desc.containsKey(area)){
                    flag = true;
                    desc.remove(area);
                }
                if (flag){
                    HashMap<Integer, Integer> map = new HashMap<>();
                    map.put(x, y);
                    desc.put(area, map);
                    flag = false;
                }
            }else if (action.equals("Delete")){
                String area = in.nextLine();
                char[] tmp = area.toCharArray();
                StringBuilder sb = new StringBuilder();
                for (int p = 1;p < tmp.length;p++){
                    sb.append(tmp[p]);
                }
                desc.remove(sb.toString());
            }
        }
        in.close();
    }


}
